﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Guest.Master" AutoEventWireup="True"
    CodeBehind="List.aspx.cs" Inherits="ScrumLite.WebUx.DeliverablesViews.List" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h1>
        <%=ViewData.ProjectName%>
    </h1>
    <hr />
   <br />
    <h2>
        Deliverables</h2>
    <br />
    <div>
        <div class="actions">
            <%= Html.ActionLink("New", "New", "Deliverables") %></div>
        <br />
        <p>
            <% if (ViewData.WorkAreasPickerViewData != null)
               { %>
            <form name="deliverablesFilterForm" id="deliverablesFilterForm" action="<%=Url.Action(new { Action="List", Controller = "Deliverables"  }) %> "
            method="post">
            <% Html.RenderPartial("WorkAreasPicker", ViewData.WorkAreasPickerViewData); %>
            </form>
            <% } %>
        </p>
        <table style="width: 100%">
            <%             
                foreach (string key in ViewData.WorkAreaDeliverables.Keys)
                {
                                            
            %>
            <tr>
                <td>
                    <b>
                        <%= key.ToString() %></b>
                </td>
            </tr>
            <%foreach (ScrumLite.WebUx.Models.DeliverableViewData item in this.ViewData.WorkAreaDeliverables[key])
              {   %>
            <tr>
                <td>
                    <ul id="deliverablesList">
                        <li><b>(w<%= GetYearWeek(item.ReleasedOn)%>)</b> <a href="<%=item.Path%>">
                            <%= item.Name %></a> (<%=  item.ReleasedOn.ToString("yyyy/MM/dd") %>) <b>
                                <% if (item.IsDefective) 
                                   { %>
                                       <span class="redText">
                                       <%Response.Write(Html.ActionLink("[Defective]", new { Action = "ReadByDeliverable", Controller = "Defects", deliverableId = item.Id.ToString() })); %>
                                       </span>
                                   <%}
                                %></b>
                            <span class="btnEdit">
                                <%=Html.ActionLink("Edit", new { Action = "Edit", Controller = "Deliverables", Id = item.Id.ToString() })%></span>
                                
                        </li>
                    </ul>
                </td>
            </tr>
            <%}
                } %>
        </table>
        <br />
        <br />
        <br />
        <div class="actions">
            <%= Html.ActionLink("New", "New", "Deliverables") %></div>
    </div>

    <script type="text/javascript" language="javascript">
    
    var urlDownload;
    
    function __showMessage(url)
    {
        
       
        var pnlMessage = document.getElementById("pnlMessage");
        urlDownload = url;   
        var lblMessage = document.getElementById("lblMessage");
        
        var calculatedTop = 1;
        var calculatedLeft = 1; 

        pnlMessage.style.top = calculatedTop;
        pnlMessage.style.left = calculatedLeft;        

        pnlMessage.style.display = "block";
        pnlMessage = null;
    }
    
    function __hideMessage()
    {
    
       var pnlMessage = document.getElementById("pnlMessage");
        
        pnlMessage.style.display = "none";
        
        pnlMessage = null;    
    }
    
    function btnAgree_Click()
    {
        //Code for download.
        document.location = urlDownload;
    }
    </script>

    <div id="pnlMessage">
        <p>
            <span id="lblTitle"><b>Warning</b></span>
        </p>
        <div id="lblMessage" class="modal_content">
            <p>
                The deliverable you are downloading is defective. <i><strong>COMPANY_NAME</strong></i>
                is absolved from any and all liabilities, losses, costs, and claims that may arise
                from the usage of this deliverable in a production environment.
            </p>
            <p>
                Click <strong>'Agree'</strong> if you wish to download it or <strong>'Cancel'</strong>
                to abort the operation.
            </p>
            <div id="pnlBotones">
                <input type="button" name="btnCancel" id="btnCancel" value="Cancel" onclick="__hideMessage();" />
                <input type="button" name="btnAgree" id="btnAgree" value="Agree" onclick="btnAgree_Click()" />
            </div>
        </div>
    </div>
</asp:Content>
